package com.jojo.service.impl;

import com.jojo.component.FfmpegComponent;
import com.jojo.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class VideoServiceImpl implements VideoService {

    @Autowired
    FfmpegComponent ffmpegComponent;

    @Override
    @Async
    public void pushStream() {
        if (ffmpegComponent.isAlive()) return ; // 如果进程已经启动，则直接返回
        String cmd = "ffmpeg -re -stream_loop -1 -i " +
                "D:\\video\\为你写的歌.mp4 -c copy -f flv -flvflags no_duration_filesize rtmp://39.107.119.113:5001/live/song";
        ffmpegComponent.startProcess(cmd);

    }

    @Override
    public void stopStream() {
        ffmpegComponent.stopProcess();
    }
}
